Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up /etc/hosts file if populate_inventory_to_hosts_file is false #10144

Merged

Conversation

rptaylor
Copy link
Contributor

@rptaylor rptaylor commented May 27, 2023

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
Previously, the populate_inventory_to_hosts_file variable could only be used to prevent adding entries into /etc/hosts. Once added, there was no way to remove them except manually. Now, if populate_inventory_to_hosts_file is false, ansible will remove the entries from /etc/hosts (applying negative configuration which is good for consistency) so you don't have to manually clean them up.

Special notes for your reviewer:
Aside from removing the block indentation, the only real change is

-    state: present
+    state: "{{ 'present' if populate_inventory_to_hosts_file else 'absent' }}"

and removing the when condition from blockinfile so it always runs.

Does this PR introduce a user-facing change?:

Ensure host entries from /etc/host are absent when `populate_inventory_to_hosts_file` is false

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 27, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @rptaylor. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 27, 2023
@liupeng0518
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 29, 2023
@rptaylor
Copy link
Contributor Author

@liupeng0518 thanks for looking. Looks like the tests are successful, can you review? Thanks.

Copy link
Member

@MrFreezeex MrFreezeex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I actually needs this as well :D
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 30, 2023
@rptaylor rptaylor requested a review from MrFreezeex June 12, 2023 18:11
@rptaylor
Copy link
Contributor Author

@jayonlau @liupeng0518 can you take a look please?

/assign luckysb

@rptaylor
Copy link
Contributor Author

rptaylor commented Jul 4, 2023

This is ready to go, anyone available to look at it? Thanks.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 6, 2023
@rptaylor rptaylor force-pushed the 20230526-etchosts-idempotence branch from b6c278d to ac4d563 Compare July 6, 2023 18:42
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 6, 2023
@rptaylor rptaylor force-pushed the 20230526-etchosts-idempotence branch from ac4d563 to 1c2d082 Compare July 6, 2023 18:46
Copy link
Member

@MrFreezeex MrFreezeex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 6, 2023
@rptaylor
Copy link
Contributor Author

rptaylor commented Jul 6, 2023

@LuckySB or @yankay can you please have a look before it needs rebasing again? Thanks.

@rptaylor
Copy link
Contributor Author

rptaylor commented Aug 9, 2023

Is there anyone available to review this MR?
@floryut ?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 11, 2023
@yankay
Copy link
Member

yankay commented Aug 11, 2023

Thanks @rptaylor

There needs a rebase :-)
It's /lgtm

@rptaylor rptaylor force-pushed the 20230526-etchosts-idempotence branch from 1c2d082 to 04a3b67 Compare August 11, 2023 18:57
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 11, 2023
@rptaylor
Copy link
Contributor Author

@yankay Can you please review it now before it needs rebasing yet again? Thanks.

@MrFreezeex
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 11, 2023
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 14, 2023
@MrFreezeex
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 15, 2023
@yankay
Copy link
Member

yankay commented Aug 16, 2023

Thanks @rptaylor
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MrFreezeex, rptaylor, yankay

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 16, 2023
@k8s-ci-robot k8s-ci-robot merged commit cf3b3ca into kubernetes-sigs:master Aug 16, 2023
@rptaylor rptaylor deleted the 20230526-etchosts-idempotence branch August 16, 2023 19:02
@yankay yankay mentioned this pull request Aug 24, 2023
guytet pushed a commit to guytet/kubespray that referenced this pull request Oct 30, 2023
…kubernetes-sigs#10144)

* de-populate hosts file if populate_inventory_to_hosts_file is false

keep newline

* fix when condition
pedro-peter pushed a commit to pedro-peter/kubespray that referenced this pull request May 8, 2024
…kubernetes-sigs#10144)

* de-populate hosts file if populate_inventory_to_hosts_file is false

keep newline

* fix when condition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants